#!/bin/bash
# EbbFlow Node Setup Script

# Update system
yum update -y

# Install Go
curl -O https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile

# Install dependencies
yum install -y git make gcc

# Clone and build EbbFlow
cd /home/ec2-user
git clone <EBBFLOW_REPO_URL> ebbflow
cd ebbflow
make

# Create logger directory
mkdir -p logger

# Start EbbFlow server with logging
./bin/ebbflow_server 0 --logger --logdir logger &
